{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n",
    "logging.basicConfig(level=logging.ERROR)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length (cm)</th>\n",
       "      <th>sepal width (cm)</th>\n",
       "      <th>petal length (cm)</th>\n",
       "      <th>petal width (cm)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)\n",
       "0                5.1               3.5                1.4               0.2\n",
       "1                4.9               3.0                1.4               0.2\n",
       "2                4.7               3.2                1.3               0.2"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.datasets import load_iris\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "X, y = load_iris(return_X_y=True, as_frame=True)\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
    "X[:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "1    0\n",
       "2    0\n",
       "Name: target, dtype: int64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y[:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17:18:57 I hypergbm.experiment.py 679 - create experiment with ['data_clean', 'drift_dected', 'base_search_and_train']\n",
      "17:18:57 I hypernets.m.hyper_model.py 249 - 3 class detected, inferred as a [multiclass classification] task\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "### Input Data"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_train.shape</th>\n",
       "      <th>y_train.shape</th>\n",
       "      <th>X_eval.shape</th>\n",
       "      <th>y_eval.shape</th>\n",
       "      <th>X_test.shape</th>\n",
       "      <th>Task</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(120, 4)</td>\n",
       "      <td>(120,)</td>\n",
       "      <td>(30, 4)</td>\n",
       "      <td>(30,)</td>\n",
       "      <td>(30, 4)</td>\n",
       "      <td>multiclass(3)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  X_train.shape y_train.shape X_eval.shape y_eval.shape X_test.shape  \\\n",
       "0      (120, 4)        (120,)      (30, 4)        (30,)      (30, 4)   \n",
       "\n",
       "            Task  \n",
       "0  multiclass(3)  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAhUAAAEkCAYAAACYKsPrAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAxOAAAMTgF/d4wjAAAX6ElEQVR4nO3df5RndX3f8ecLdvlRZrOEdRFx2W5xQTymAkZjbCNRPNpiLVghGnooylHA0q3GradatNYTbaKoG2s9KgQV1FiNIQdi/J2qUas0qGAUi/xyHUZ+KEtX2CiwsO/+MXfK90xmdr8z85md7519PvbcM/O9n3s/9/2Zu3f2tffe7/2mqpAkSVqo/Za6AEmStDwYKiRJUhOGCkmS1IShQpIkNWGokCRJTRgqJElSE4YKSZLUhKFC6okkFyb5wiL0e32Sl3Tfb0hSSTYuwnY+m+Q/t+53jjWsTPInSe5JsiPJ6qWsR1pu4sOvpKWV5CvAPwEeAHYB9wLfBv64qj49zz63Am+pqkvnuN4G4EfAMVV18zy3veA+FkuSM4F3AsdV1b1LXY+03HimQhoNF1XVqqpaDfw68AXg40n+62JtMMkBi9X3CHsccKuBQlochgppxFTVT6vqvcDvAa+buhSR5E1Jvj61XJJNSW5Jcl+Su5Jc1s3/LLAeeE93iv/6wfWTvDnJ7cB13fytSV4+rYxnJflBknuT/M8kjxvY7leSvGVw4Wl9XN99/W63/ffPtF6SJ3SXRO5OMpHk4sHLEd3y/y3Jx5L8PMltSf7t7n52u+uz+/m8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uo509Iz3AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 640x320 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17:18:57 I tabular_toolbox.data_cleaner.py 243 - dataframe meta:{'float64': ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']}\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "### Data Cleaner"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "None"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "### Train set & Eval set"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_train.shape</th>\n",
       "      <th>y_train.shape</th>\n",
       "      <th>X_eval.shape</th>\n",
       "      <th>y_eval.shape</th>\n",
       "      <th>X_test.shape</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(120, 4)</td>\n",
       "      <td>(120,)</td>\n",
       "      <td>(30, 4)</td>\n",
       "      <td>(30,)</td>\n",
       "      <td>(30, 4)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  X_train.shape y_train.shape X_eval.shape y_eval.shape X_test.shape\n",
       "0      (120, 4)        (120,)      (30, 4)        (30,)      (30, 4)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "### Drift detection"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17:18:57 I tabular_toolbox.drift_detection.py 136 - Feature selection to try to eliminate the concept drift.\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 412 - Preprocessing...\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 421 - Scoring...\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 438 - column:sepal length (cm), score:0.48456790123456783\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 438 - column:sepal width (cm), score:0.39043209876543206\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 438 - column:petal length (cm), score:0.5030864197530864\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 438 - column:petal width (cm), score:0.5401234567901234\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 165 - \n",
      "Round: 1\n",
      "\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 229 - Fit data for concept drift detection\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 267 - Preprocessing...\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 286 - Fold:1\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 310 - auc: 0.5\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 286 - Fold:2\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 310 - auc: 0.5\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 286 - Fold:3\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 310 - auc: 0.5\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 286 - Fold:4\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 310 - auc: 0.5\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 286 - Fold:5\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 310 - auc: 0.5\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 168 - AUC:0.5, Features:['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']\n",
      "17:18:57 I tabular_toolbox.drift_detection.py 177 - AUC:0.5 has dropped below the threshold:0.55, feature selection is over.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>no drift features</td>\n",
       "      <td>[sepal length (cm), sepal width (cm), petal le...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>history</td>\n",
       "      <td>[{'auc': 0.5, 'n_features': 4, 'elapsed': 0.11...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>drift score</td>\n",
       "      <td>{'sepal length (cm)': 0.48456790123456783, 'se...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 key                                              value\n",
       "0  no drift features  [sepal length (cm), sepal width (cm), petal le...\n",
       "1            history  [{'auc': 0.5, 'n_features': 4, 'elapsed': 0.11...\n",
       "2        drift score  {'sepal length (cm)': 0.48456790123456783, 'se..."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "### Pipeline search"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17:18:57 I hypernets.m.hyper_model.py 249 - 3 class detected, inferred as a [multiclass classification] task\n",
      "17:18:57 I hypernets.c.meta_learner.py 22 - Initialize Meta Learner: dataset_id:74e7c134740a0f846f4c5e57fa5e6c93\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>trial No.</th>\n",
       "      <th>Previous reward</th>\n",
       "      <th>Best trial</th>\n",
       "      <th>Best reward</th>\n",
       "      <th>Total elapsed</th>\n",
       "      <th>Max trials</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.900597</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   trial No.  Previous reward  Best trial  Best reward  Total elapsed  \\\n",
       "0         10              1.0           1          1.0       2.900597   \n",
       "\n",
       "   Max trials  \n",
       "0          10  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "#### Current Trial:"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Trial No.</th>\n",
       "      <th>Reward</th>\n",
       "      <th>Elapsed</th>\n",
       "      <th>Space Vector</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.165199</td>\n",
       "      <td>[1, 2, 0, 1, 460, 0, 0, 0, 4]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.147101</td>\n",
       "      <td>[1, 2, 1, 0, 440, 2, 3, 3, 0, 3]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.266733</td>\n",
       "      <td>[0, 1, 0, 1, 0, 1, 1, 0, 1, 1]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.220638</td>\n",
       "      <td>[0, 2, 1, 2, 3, 1, 2, 2, 2, 1, 1]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.234070</td>\n",
       "      <td>[2, 3, 0, 2, 0, 2]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Trial No.  Reward   Elapsed                       Space Vector\n",
       "0          1     1.0  0.165199      [1, 2, 0, 1, 460, 0, 0, 0, 4]\n",
       "1          2     1.0  0.147101   [1, 2, 1, 0, 440, 2, 3, 3, 0, 3]\n",
       "2          3     1.0  0.266733     [0, 1, 0, 1, 0, 1, 1, 0, 1, 1]\n",
       "3          5     1.0  0.220638  [0, 2, 1, 2, 3, 1, 2, 2, 2, 1, 1]\n",
       "4          6     1.0  0.234070                 [2, 3, 0, 2, 0, 2]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "#### Best Trial:"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "<thead>\n",
       "<tr style=\"text-align: right;\">\n",
       "  <th>key</th>\n",
       "  <th>value</th>\n",
       "</tr>\n",
       "</thead>\n",
       "<tbody><tr>\n",
       "  <td>signature</td>\n",
       "  <td>c6b5e78c1b19a003b29861099b81e9c4</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <td>vectors</td>\n",
       "  <td>[1, 2, 0, 1, 460, 0, 0, 0, 4]</td>\n",
       "</tr><tr>\n",
       "  <td>0-estimator_options.hp_or</td>\n",
       "  <td>1</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>1-numeric_imputer_0.strategy</td>\n",
       "  <td>constant</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>2-numeric_scaler_optional_0.hp_opt</td>\n",
       "  <td>False</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>3-Module_LightGBMEstimator_1.boosting_type</td>\n",
       "  <td>dart</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>4-Module_LightGBMEstimator_1.num_leaves</td>\n",
       "  <td>460</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>5-Module_LightGBMEstimator_1.max_depth</td>\n",
       "  <td>3</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>6-Module_LightGBMEstimator_1.learning_rate</td>\n",
       "  <td>0.001</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>7-Module_LightGBMEstimator_1.reg_alpha</td>\n",
       "  <td>0.001</td>\n",
       "</tr>\n",
       "<tr><tr>\n",
       "  <td>8-Module_LightGBMEstimator_1.reg_lambda</td>\n",
       "  <td>1</td>\n",
       "</tr>\n",
       "<tr>  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "DAG_HyperSpace_1"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17:18:57 I hypernets.d.in_process_dispatcher.py 119 - Trial 1 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:18:58 I hypernets.d.in_process_dispatcher.py 119 - Trial 2 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:18:58 I hypernets.d.in_process_dispatcher.py 119 - Trial 3 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:18:58 I hypernets.d.in_process_dispatcher.py 119 - Trial 4 done, reward: 0.3, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:18:58 I hypernets.d.in_process_dispatcher.py 119 - Trial 5 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:18:59 I hypernets.d.in_process_dispatcher.py 119 - Trial 6 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:18:59 I hypernets.d.in_process_dispatcher.py 119 - Trial 7 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:19:00 I hypernets.d.in_process_dispatcher.py 119 - Trial 8 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:19:00 I hypernets.d.in_process_dispatcher.py 119 - Trial 9 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n",
      "17:19:00 I hypernets.d.in_process_dispatcher.py 119 - Trial 10 done, reward: 1.0, best_trial_no:1, best_reward:1.0\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "### Ensemble"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>weights</td>\n",
       "      <td>[1.0, 0.0, 0.0, 0.0, 0.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scores</td>\n",
       "      <td>[1.0, 1.0, 1.0, 1.0, 1.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>best_stack</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>hits</td>\n",
       "      <td>{0: 5}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ensemble_size</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "GreedyEnsemble(weight=[1. 0. 0. 0. 0.], estimators=[LGBMClassifierWrapper(boosting_type='dart', learning_rate=0.001, max_depth=3,\n",
       "                      n_estimators=200, num_leaves=460, reg_alpha=0.001,\n",
       "                      reg_lambda=1), None, None, None, None])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "Pipeline(steps=[('data_clean',\n",
       "                 <hypergbm.experiment.DataCleanStep object at 0x1a34378590>),\n",
       "                ('drift_dected',\n",
       "                 <hypergbm.experiment.DriftDetectStep object at 0x10b55ddd0>),\n",
       "                ('base_search_and_train',\n",
       "                 <hypergbm.experiment.BaseSearchAndTrainStep object at 0x10b55db90>),\n",
       "                ('estimator',\n",
       "                 GreedyEnsemble(weight=[1. 0. 0. 0. 0.], estimators=[LGBMClassifierWrapper(boosting_type='dart', learning_rate=0.001, max_depth=3,\n",
       "                      n_estimators=200, num_leaves=460, reg_alpha=0.001,\n",
       "                      reg_lambda=1), None, None, None, None]))])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from hypergbm.search_space import search_space_general\n",
    "from hypergbm import HyperGBM, CompeteExperiment\n",
    "from hypernets.searchers.evolution_searcher import EvolutionSearcher\n",
    "from sklearn.metrics import get_scorer\n",
    "\n",
    "rs = EvolutionSearcher(search_space_general,  200, 100, optimize_direction='max')\n",
    "hk = HyperGBM(rs, task='multiclass', reward_metric='accuracy', callbacks=[])\n",
    "\n",
    "experiment = CompeteExperiment(hk, X_train, y_train, X_test, y_test, callbacks=[], scorer=get_scorer('accuracy'),\n",
    "                               ensemble_size=5)  # enable ensemble\n",
    "\n",
    "pipeline = experiment.run(max_trials=10)\n",
    "pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "y_pred = pipeline.predict(X_test).astype(np.float64)\n",
    "\n",
    "from sklearn.metrics import accuracy_score\n",
    "accuracy_score(y_pred, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
